package com.butterfly.domain.dao;


import com.butterfly.domain.entity.PointConfiguration;
import com.butterfly.domain.entity.UserPointCapture;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import javax.inject.Named;

@Named
public class UserPointCaptureDAOImpl extends AbstractDaoHibernate<UserPointCapture> implements UserPointCaptureDAO {
    @Override
    protected Class<UserPointCapture> getEntityClass() {
        return UserPointCapture.class;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public UserPointCapture getUserPoint(int userId) {
        Criteria criteria = getSession().createCriteria(PointConfiguration.class);
        criteria.add(Restrictions.eq("user", userId));
        if (criteria.list().size() > 0) {
            return (UserPointCapture) criteria.list().get(0);
        }
        return null;
    }
}
